@extends('admin.layouts.app')
@section('content')

                        <!-- Page-Title -->
                        <div class="row">
                            <div class="col-sm-12">
                                <h4 class="page-title">维修内容管理</h4>
                                <ol class="breadcrumb">
                                    <li><a href="{{url('zadmin/')}}">系统</a></li>
                                   
                                    <li class="active">维修内容列表</li>
                                </ol>
                            </div>
                        </div>
                        
                        <div class="row">
                        	<div class="col-lg-12">
                        		<div class="card-box">
                        			<div class="row">
			                        	<div class="col-sm-5">
			         <form role="form">
			           <div class="form-group contact-search col-sm-8">
			              <input type="text" id="search" class="form-control" placeholder="Search..." name="keyword">
			                                        
			           </div>
                  <div class="col-sm-2">
                    <button type="button" class="btn btn-white btn-sm" id="srcBtn"><i class="fa fa-search"></i>搜索</button>
                  </div> 
                  <div class="col-sm-2">
                    <button  class="btn btn-success btn-sm" id="exportBtn" type="button"><i class="md  md-file-download">导出</i></button>
                  </div>
			                                </form>
			                        	</div>
			                        	

                                 <div class="col-sm-6">
                <form enctype="multipart/form-data" method="post"  id="form1">                                  
                  <div class="col-sm-5">
                    <input type="file" required=""  name="excel" class="form-control" >
                  
                  </div>
                  <div class="col-sm-2">
                    <button  class="btn btn-danger  waves-effect waves-light m-b-30 btn-sm btn-submit" ><i class="md  md-file-upload">导入</i></button>
                  </div>
                   
                  <div class="col-sm-2">
                    <a href="{{url('excel/批量导入项目模板.xlsx')}}"  class="btn btn-default  waves-effect waves-light m-b-30 btn-sm"><i class="md  md-file-download">模板</i></a>
                  </div>
                  <div class="col-sm-1"> 
                  <a href="{{url('zadmin/services/create')}}" class="btn btn-primary  waves-effect waves-light m-b-30 btn-sm" ><i class="md md-add"></i>添加</a>
                </div>
                               
                  {{csrf_field()}}
                </form>
                </div>
			                        </div>

                              @if(session('rs'))
                              <div class="alert alert-{{session('rs')['status']}}">
                                {{ session('rs')['msg'] }}
                              </div>
                              @endif
			                        
                        			<div class="table-responsive">
                                        <table class="table table-hover">
                                        	<thead>
												<tr>
													<th style="min-width: 35px;">
													<input id="checkAll" type="checkbox" value=""/>全选
                                                        
													</th>
													<th>服务名称</th>
													<th>类别</th>
                          <th>定价方式</th>
                          <th>工时费</th>
                          <th>工时</th>
                          <th>总价</th>
                         
                         
													<th style="width: 200px;">操作</th>
												</tr>
											</thead>
											
                                            <tbody>

                                            @foreach($list as $v)
                                                <tr>
                        <td>                                                 <input  name="ids[]" type="checkbox" value="{{$v->id}}" class="check_class">
                                                        
                                                      
                                                    </td>
                                                    
                                              <td>
                                  {{$v->name}}
                                                    </td>
                          <td>{{object_get($v,'type.name')}}</td>
                            <td>{{$v->price_type_txt}}</td>
                            <td>{{$v->gongshi_fee}}</td>
                            <td>{{$v->gongshi}}</td>
                            <td>
                                {{$v->price}}
                            </td>
                                                    
                                                    
                                                    
                                                
                                                    
                                                   
                                                    <td>
                                                    	<a href="{{url('zadmin/services/'.$v->id.'/edit')}}" ><i class="md md-edit"></i>编辑</a>
                                                    	<a href="{{url('zadmin/services',$v->id)}}" data-method="delete" 
  data-token="{{csrf_token()}}" data-confirm="确定删除吗?"><i class="md md-close"></i>删除</a>
                                                    </td>
                                                </tr>
                                            @endforeach    
                                                
                                               
                                               
                                                
                                               
                                                
                                            
                                            </tbody>
                                        </table>
                                        <button type="button" class="btn btn-sm btn-danger bathDel">批量删除</button>
                                    </div>
                                    {{$list->links()}}
                        		</div>
                                
                            </div> <!-- end col -->

                            
                        </div>
@endsection
                        
                        
                        

                  
            
    @section('modal')        
        <!-- Modal -->
      <div id="custom-modal" class="modal-demo">
          <button type="button" class="close" onclick="Custombox.close();">
              <span>&times;</span><span class="sr-only">Close</span>
          </button>
          <h4 class="custom-modal-title">添加维修内容</h4>
          <div class="custom-modal-text text-left">
              <form class="form-horizontal" role="form" action="{{url('zadmin/services')}}" method="post" enctype="multipart/form-data">                                    
                                              <div class="form-group">
                                                  <label class="col-md-2 control-label">名称</label>
                                                  <div class="col-md-10">
                                                      <input type="text" class="form-control" name="name" value="" required="">
                                                  </div>
                                              </div>
                                              
                                                                                                                    
                                              <div class="form-group">
                                                  <label class="col-md-2 control-label">价格</label>
                                                  <div class="col-md-10">
                                                      <input class="form-control"  name="price" />
                                                  </div>
                                              </div>

                                              <div class="form-group text-center">
                                                  
                                                  <button type="submit" class="btn btn-info waves-effect waves-light">保存</button>
                                              </div>
                                              
                                              
                             {{csrf_field()}}
                                          </form>
          </div>
      </div>
    @endsection 

    @section('js')
    <script type="text/javascript">
    $('#checkAll').click(function () {    
      $('input:checkbox').prop('checked', this.checked);    
    });

    $('#srcBtn').on('click',function(){
      var url = "{{url('zadmin/services')}}";
      $('#form1').attr('action',url).submit(); 
    });
    $('#exportBtn').on('click',function(){
      var url = "{{url('zadmin/services/export')}}";
      $('#form1').attr('action',url).submit(); 
    });

    $('.btn-submit').on('click',function(){
      var url = "{{url('zadmin/services/import')}}";
      $('#form1').attr('action',url).submit();
    });

  $('.bathDel').on('click',function(){
    var ids = $('.check_class:checked').map(function() {
      return this.value;
    }).get();
    if(ids==''){
      alert('请选择要删除的数据');return;
    }
    var url="{{url('zadmin/services/bath-del')}}";
    var data = {};
    data.ids = ids;
    data._token = "{{csrf_token()}}";
    $.post(url,data,function(rs){
      if(rs.status==true) {
        window.location.reload();
      }
    });
    console.info(ids);
  });
    
    
  
    </script>
    @endsection       
       

           



    
        
    
